<?php
namespace Admin\Controller;
use Think\Controller;
class ClubController extends Controller {
    public function index(){
        $this->display();
    }
    //列表
    public function clublist(){
        $clubmodel=M('club');
        $clubs=$clubmodel->order('cid')->select();
        $this->club=$clubs;
        $this->display();
	}
	//删除
	public function delclub($cid){
	$clubmodel=M('club');	
	if (false!==$clubmodel->where("cid=$cid")->delete()) {
            $this->success('删除成功！');
        } else {
            $this->error('删除失败');
        }
		
	}
	//添加
    public   function clubadd(){
        $clubs = D('club'); 
        $data['cname']=I('post.cname');
        $data['cintroduce']=I('post.cintroduce');
        $data['caddress']=I('post.caddress');
        $data['ctel']=I('post.ctel');
        $data['ctime']=I('post.ctime');  
        $data['cpic']=I('post.cpic');
        dump($data);
        
         if(false!==$clubs->add($data)){
             $this->success('成功','clublist');
         }else{
            $this->error('失败','clublist');
         }
        }

		//修改
        public   function editclub(){

              $clubs = D('club'); 
              $cid=I('post.cid');
        $data['cname']=I('post.cname');
        $data['cintroduce']=I('post.cintroduce');
        $data['caddress']=I('post.caddress');
        $data['ctel']=I('post.ctel');
        $data['atel']=I('post.atel');  
        $data['ctime']=I('post.ctime');
        dump($data);
        if(false !== $clubs->where("cid=$cid")->save($data)){
            $this->success('成功','clublist');
         }else{
            $this->error('失败');
         }
        }
        
        public function edit(){    
            $clubs = D('club'); 
            $cid=$_GET['cid'];
            $res= $clubs->where("cid=$cid")->find();
            $this->club=$res;
         
        $this->display();
        }
}